.SUFFIXES: .asm .c .cpp

SUBDIR := drives kernel

CC=gcc
CXX=g++
ASM=nasm

CFLAGS=
CXXLAGS=
LFLAGS=-T linker.ld
ASMFLAGS=-f elf

OBJS=\
	start.o 			\
	main.o 				\
	drives/video.o 			\
	kernel/io.o 			\
	kernel/intr.o			\
	drives/keyboard.o		\
	kernel/common.o			\
	kernel/string.o			\
	kernel/kernel.o 		\
	kernel/commands.o

OBJS_LOC=\
	../bin/start.o 			\
	../bin/main.o 			\
	../bin/drives/video.o 		\
	../bin/kernel/io.o 		\
	../bin/kernel/intr.o		\
	../bin/drives/keyboard.o	\
	../bin/kernel/common.o		\
	../bin/kernel/string.o		\
	../bin/kernel/kernel.o 		\
	../bin/kernel/commands.o	

Lascaux.iso: kernel.bin
	cp ../bin/kernel.bin ../iso/boot/kernel.bin
	grub-mkrescue -o ../Lascaux.iso ../iso

kernel.bin: $(OBJS)
	@echo " ----- "
	@echo "ld $(LFLAGS) -o ../bin/$@ (...)"
	@ld $(LFLAGS) -o ../bin/$@ $(OBJS_LOC)

.asm.o:
	$(ASM) $(ASMFLAGS) -o ../bin/$@ $<

.c.o:
	$(CC) $(CFLAGS) -o ../bin/$@ -c $<

.cpp.o:
	$(CXX) $(CXXLAGS) -o ../bin/$@ -c $<



clean:
	rm -f ../bin/*.o